package sort;

import java.util.Arrays;

/**
 * @Author: fzykd
 * Date: 2024-04-17
 * Time: 22:08
 * User: LQH
 */


public class ChoiceSort {
    public static void main(String[] args) {
        int[] arr = {3, 12, 10, 6, 5};
        for (int i = 0; i < arr.length; i++) {
            int minIndex = i;
            for (int j = i + 1; j < arr.length; j++) {
                //找到最小下标位置
                if (arr[j] < arr[minIndex]) {
                    minIndex = j;
                }
            }

            int tmp = arr[i];
            arr[i] = arr[minIndex];
            arr[minIndex] = tmp;
        }

        System.out.println(Arrays.toString(arr));
    }
}
